package logic.nodes;

import logic.nodes.damagable.DamagableNode;
import logic.nodes.damagable.shield.ShieldBoundController;

public class ModelNodeBoundController extends BoundController {
	
	private static final long serialVersionUID = 1L;
		
	public ModelNodeBoundController(ModelNode node) {
		super(node);
	}
	
	@Override
	protected boolean ready() {
		boolean worldBoundDone = node.getWorldBound() != null;
		if(node instanceof SlotNode) {
			SlotNode slotNode = (SlotNode)node;
			worldBoundDone &= slotNode.slotsDone();
		}
		return worldBoundDone;
	}
	
	@Override
	protected void performAction(float time) {
		node.setBound(node.getWorldBound().clone(null));
		setActive(false);
		if(node instanceof DamagableNode) {
			DamagableNode dNode = (DamagableNode)node;
			ShieldBoundController c = new ShieldBoundController(dNode);
			dNode.addController(c);
		}
		node.lockNode();
	}
}